# -*- utf-8 -*-
import requests
import urllib
import urllib2
import mp3play
import os
import time
from Tkinter import *

def read(event=None):
	word=e.get()
	if(os.path.exists(word+'.mp3')):
		pass
	else:
		urllib.urlretrieve('http://fanyi.baidu.com/gettts?lan=uk&text='+word+'&spd=3&source=web', word+'.mp3')
	filename=word+'.mp3'
	clip=mp3play.load(filename)
	clip.play()
	time.sleep(clip.seconds())
	clip.stop()

root=Tk()
root.resizable(False, False)
e=StringVar()
entry=Entry(root, validate='key', textvariable=e, width=50)
entry.bind('<Return>', read)
entry.pack()
root.mainloop()
